<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String cpath = request.getContextPath();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>조립PC의 대명사- PC Master~!~!</title>
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.0.0.js"></script>
<script>
	$(function() { 
		$("#check_all").click(function() {
			var chk = $(this).is(":checked");
       	 	if(chk) $("input:checkbox[name='cart_check']").prop('checked', true);
       		else  $("input:checkbox[name='cart_check']").prop('checked', false);
       	 });
	});
	function modify() {
		var checkArry = $("input:checkbox[name='cart_check']");
		var checkArrys = "";
		var amountArry = $("input[name='amount']");
		var amountArrys = "";
		var sumArry = $("input[name='sumprice']");
		var sumArrys = "";
		if($("input:checkbox[name='cart_check']:checked").length == 0) {
			alert("체크가 되어있지 않습니다.");
			return;
		}
		for ( var i = 0; i < checkArry.length; i++) {
			if(checkArry[i].checked == true) {
				if (checkArrys == "") {
					checkArrys = checkArrys + "?Cart_Nums=" + checkArry[i].value;
					amountArrys = amountArrys + "&Cart_GoodsAmounts="+ amountArry[i].value;
					sumArrys = sumArrys + "&Cart_Sums="+ sumArry[i].value;
				} else {
					checkArrys = checkArrys + "&Cart_Nums=" + checkArry[i].value;
					amountArrys = amountArrys + "&Cart_GoodsAmounts="+ amountArry[i].value;
					sumArrys = sumArrys + "&Cart_Sums="+ sumArry[i].value;
				}
			}
		}
		location.href = "/web/cart/update" + checkArrys + amountArrys + sumArrys;
	}
	function remove() {
		var checkArry = $("input:checkbox[name='cart_check']");
		var checkArrys = "";
		if ($("input:checkbox[name='cart_check']:checked").length == 0) {
			alert("체크가 되어있지 않습니다.");
			return;
		}
		for ( var i = 0; i < checkArry.length; i++) {
			if (checkArry[i].checked == true) {
				if (checkArrys == "") {
					checkArrys = checkArrys + "?Cart_Nums=" + checkArry[i].value;
				} else {
					checkArrys = checkArrys + "&Cart_Nums=" + checkArry[i].value;
				}
			}
		}
		location.href = "/web/cart/delete" + checkArrys;
	}
</script>
</head>
<body>
<!-- 상단 로그인 패널을 include로 삽입 -->
<div style="position:absolute; left:50%; top:0px; width:1200px; height:80px; margin-left:-600px;z-index:1 ">
<%@ include file="../loginPanel.jsp" %>
</div>

<!-- 상단 및 좌측 메뉴(카테고리)리스트를 include로 삽입 -->
<div style="position:absolute; left:50%; top:0px; width:1200px; height:80px; margin-left:-600px;">
<%@ include file="../top.jsp" %>
</div>

<div style="position:absolute; left:50%; top:160px; width:1000px; height:80px; margin-left:-400px;">
<!--------------------------------------여기다가 각자 삽입------------------------------------>
<table style="margin-left:30px; margin-top:30px" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td><img src="/web/resources/images/bar_t_line.gif" border="0" alt="" /></td>
		<td style="color:333333;font-size:14px;font-weight:bold;">장바구니</td>
	</tr>
</table>

			<input type="image" src="<%=cpath %>/resources/images/btn_cart_nummodify.gif" onclick="modify();"/>
			<input type="image" src="<%=cpath %>/resources/images/btn_cart_delete.gif" onclick="remove();"/>
			
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr> 
		<td bgcolor="E3E3E3" height="1"></td>
	</tr>
	<tr> 
		<td bgcolor="F7F7F7" height="2"></td>
	</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr> 
		<td height="25"> 
			<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
            	<tr> 
                	<td align="center" width="70">
                		<input type="checkbox" id="check_all" />
                		<font color="#000000"></font>
                	</td>
                    <td width="1"> 
                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                        	<tr> 
                            	<td height="10" bgcolor="#e3e3e3"></td>
                            </tr>
						</table>
					</td>
                    <td align="center"><font color="#000000">제품명</font></td>
                    <td width="1"> 
                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                        	<tr> 
                            	<td height="10" bgcolor="#e3e3e3"></td>
                            </tr>
                        </table>
					</td>
					<td align="center" width="150"><font color="#000000">옵션</font></td>
					<td width="1"> 
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr> 
								<td height="10" bgcolor="#e3e3e3"></td>
                            </tr>
						</table>
					</td>
                    <td align="center" width="90"><font color="#000000">가격</font></td>
                    <td width="1"> 
                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                    		<tr> 
                            	<td height="10" bgcolor="#e3e3e3"></td>
                            </tr>
                    	</table>
					</td>
					<td align="center" width="70"><font color="#000000">적립금</font></td>
					<td width="1"> 
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr> 
								<td height="10" bgcolor="#e3e3e3"></td>
                            </tr>
                        </table>
                    </td>
					<td align="center" width="60"><font color="#000000">수량</font></td>
					<td width="1"> 
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr> 
								<td height="10" bgcolor="#e3e3e3"></td>
							</tr>
						</table>
					</td>
					<td align="center" width="100"><font color="#000000">합계</font></td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr> 
		<td bgcolor="E3E3E3" height="1"></td>
	</tr>
	<tr> 
		<td bgcolor="F7F7F7" height="2"></td>
	</tr>
</table>
<table>
	<c:set var="sumcount" value="0" />
	<c:forEach items="${listBean }" var="item">
	<c:set var="sumcount" value="${sumcount + item.CART_GOODSPRICE * item.CART_GOODSAMOUNT }" />
	<tr>
		<td align="center" width="71">
			<input type="checkbox" name="cart_check" value="${item.CART_NUM }" />
		</td>
		<td align="center" >
			<table>
				<tr>
					<td>
						<img alt="상세이미지" src="/web/resources/upload/${item.CART_GOODSIMAGE}" style="width:100px; height:100px ">
					</td>	
					<td>
						<table>
							<tr>
								<td>${item.CART_GOODSNAME }</td>
							</tr>
							<tr>
								<td><img src="/web/resources/upload/${item.CART_GOODSIMAGE2}" style="width:180px; height:150px;"></td>
							</tr>
						</table> 
					</td>
				</tr>
			</table>
		</td>
		<td align="center" width="150">
			${item.CART_GOODSOPTION}
		</td>
		<td align="center" width="90">
			<fmt:formatNumber value="${item.CART_GOODSPRICE }" type="number"/>원
		</td>
		<td align="center" width="70">
			0원
		</td>
		<td align="center" width="100">
			<input type="text" name="amount" value="${item.CART_GOODSAMOUNT }" style="width: 15px;" />개
				 	/${item.CART_GOODSCOUNT }개
		</td>
		<td align="center" width="100">
			<input type="hidden" name="sumprice" value="${item.CART_GOODSPRICE * item.CART_GOODSAMOUNT }" />
			<fmt:formatNumber value="${item.CART_GOODSPRICE * item.CART_GOODSAMOUNT }" type="number"/>원
		</td>	
	</tr>
	</c:forEach>
</table>
<table>
	<tr>
		<td>
			<input type="hidden" name="sumcount" value="${sumcount }" />
			총 합계 : <fmt:formatNumber value="${sumcount }" type="number"/>원
		</td>
	</tr>
</table>
<table align="center">
	<tr >
		<td >
			<input type="image" src="<%=cpath %>/resources/images/btn_cart_order.gif" />
			<input type="image" src="<%=cpath %>/resources/images/btn_cart_shoping.gif" />
		</td>
	</tr>
</table> 
<!--------------------------------------   삽입 끝       ------------------------------------>
</div> 

<!-- 하단 이용약관, 고객센터, 회사정보 등의 정보를 include로 삽입 -->
<div style="position:absolute; left:0; top:1200px; width:100%; height:80px; ">
<%@ include file="../bottom.jsp"%>
</div>
</body>
</html>